package com.jkc.xh.adapters.viewholder;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.models.RevokeModel;
import com.jkc.xh.utils.Tool;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wangjie28 on 2015/11/13.
 */
@EViewGroup(R.layout.item_revokeview)
public class RevokeOrderItemView extends RelativeLayout {

    @ViewById(R.id.stock_name)
    TextView stock_name;

    @ViewById(R.id.create_time)
    TextView create_time;

    @ViewById(R.id.entrust_price)
    TextView entrust_price;

    @ViewById(R.id.last_price)
    TextView last_price;

    @ViewById(R.id.entrust_amount)
    TextView entrust_amount;

    @ViewById(R.id.business_amount)
    TextView business_amount;

    @ViewById(R.id.can_cancel_amount)
    TextView can_cancel_amount;

    @ViewById(R.id.status)
    TextView status;
    @ViewById(R.id.entrust_bs)
    TextView entrust_bs;

    @ViewById(R.id.btnCancel)
    Button btnCancel;

    public RevokeOrderItemView(Context context) {
        super(context);
    }

    public RevokeOrderItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void bind(RevokeModel model) {
        stock_name.setText(model.stock_name);
        create_time.setText(Tool.formatSecondSimpleFullDate(model.create_time));
        entrust_price.setText(model.entrust_price);
        last_price.setText(model.last_price);
        entrust_amount.setText(model.entrust_amount);
        business_amount.setText(model.business_amount);
        can_cancel_amount.setText(model.can_cancel_amount);
        entrust_bs.setText(model.getEntrustStatusText());
        status.setText(model.status);
        if (model.isCanCancel()) {
            btnCancel.setVisibility(View.VISIBLE);
        } else {
            btnCancel.setVisibility(View.GONE);
        }
    }

}
